<template>
	<view class="ys" v-if="info != ''">
		<view class="cdinfo">
			<view class="title">
				<text>场地信息</text>
			</view>
			<view class="item" @click="toDetail">
				<view class="imgbox">
					<image :src="info.activity_info.cover_path" mode=""></image>
				</view>
				<view class="info">
					<view class="name">
						{{info.activity_info.name}}
					</view>
					<view class="des">
						{{info.activity_info.sketch}}
					</view>
					<view class="price">
						<text class="people">查看详情</text>
						<uni-icons type="right" color="#777"></uni-icons>
					</view>
				</view>
			</view>
		</view>
		<view class="pointinfo">
			<view class="title">
				<text>预约凭证</text>
			</view>
			<view class="codeimg">
				<uqrcode ref="uqrcode" canvas-id="qrcode" :value="info.order_no" @longtap="save">
				</uqrcode>
			</view>
			<view class="tips">
				出示二维码核销入园
			</view>
		</view>
		<view class="pointinfo">
			<view class="title">
				<text>预约信息</text>
			</view>
			<view class="pli">
				<view class="left">
					姓名
				</view>
				<view class="right">
					{{info.name}}
				</view>
			</view>
			<view class="pli">
				<view class="left">
					联系方式
				</view>
				<view class="right">
					{{info.phone}}
				</view>
			</view>
			<view class="pli">
				<view class="left">
					证件类型
				</view>
				<view class="right">
					{{info.card_type.text}}
				</view>
			</view>
			<view class="pli">
				<view class="left">
					证件号
				</view>
				<view class="right">
					{{info.card_number}}
				</view>
			</view>
			<view class="pli">
				<view class="left">
					预约时间
				</view>
				<view class="right">
					{{info.appoint_date}}
				</view>
			</view>
			<view class="pli">
				<view class="left">
					时间段
				</view>
				<view class="right">
					{{info.appoint_time}}
				</view>
			</view>
			<view class="pli">
				<view class="left">
					预约类型
				</view>
				<view class="right">
					{{info.type.text}}
				</view>
			</view>
			<view class="pli">
				<view class="left">
					预约人数
				</view>
				<view class="right">
					{{info.appoint_count}}人
				</view>
			</view>

		</view>
	</view>
</template>

<script>
	import {
		appointDetail
	} from "@/api/api.js"
	export default {
		data() {
			return {
				id: '',
				info: []
			}
		},
		onReady() {
			if (this.$refs.uqrcode) {
				this.$refs.uqrcode.toTempFilePath({
					success: res => {}
				});
			}
		},
		onLoad(e) {
			if (e.id) {
				this.id = e.id
				this.appointDetail()
			}
		},
		methods: {
			toDetail() {
				if (this.info.activity) {
					uni.navigateTo({
						url: `/pages/venue/index?id=${this.info.activity.id}`
					})
				}
			},
			appointDetail() {
				appointDetail({
					id: this.id
				}).then(res => {
					if (res.status == 1) {
						this.info = res.data
					}
				})
			},
			save() {
				this.$refs.uqrcode.save({
					success: () => {
						uni.showToast({
							icon: 'success',
							title: '保存成功'
						});
					}
				});
			}
		}
	}
</script>

<style lang="scss">
	page {
		background: #f2f2f2;
		padding: 10px 0;
	}

	.title {
		font-weight: bold;
		margin-bottom: 20px;
		font-size: 17px;

		text {
			position: relative;

			&::after {
				content: '';
				width: 30px;
				height: 3px;
				background: #8E060A;
				left: 0;
				bottom: -10px;
				border-radius: 20px;
				position: absolute;
			}
		}
	}

	.cdinfo {
		background: #fff;
		width: 96%;
		padding: 10px;
		box-sizing: border-box;
		border-radius: 8px;
		margin: 0 auto;



		.item {
			display: flex;
			background: #fff;
			border-radius: 8px;
			box-sizing: border-box;
			padding-right: 10px;
			margin-top: 15px;

			.imgbox {
				width: 40%;

				image {
					width: 100%;
					height: 110px;
					border-radius: 5px;
				}
			}

			.info {
				flex: 1;
				padding-left: 10px;

				.name {
					font-weight: bold;
					font-size: 15px;
					margin-top: 8px;
				}

				.des {
					font-size: 12px;
					color: #999;
					display: -webkit-box;
					-webkit-line-clamp: 2;
					-webkit-box-orient: vertical;
					overflow: hidden;
					margin-top: 10px;
				}

				.price {
					margin-top: 20px;
					font-size: 12px;
					color: #777;
					display: flex;
					justify-content: space-between;
					align-items: center;
				}
			}
		}
	}

	.pointinfo {
		background: #fff;
		width: 96%;
		margin: 10px auto;
		padding: 10px;
		box-sizing: border-box;
		border-radius: 8px;

		.codeimg {
			display: flex;
			align-items: center;
			justify-content: center;
			padding-top: 10px;

			image {
				width: 140px;
				height: 140px;
			}
		}

		.tips {
			text-align: center;
			font-size: 12px;
			color: #777;
			padding: 10px 0;
		}

		.pli {
			display: flex;
			align-items: center;
			font-size: 14px;
			padding: 5px 0;

			.left {
				width: 100px;
			}
		}
	}
</style>